home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_4.zip / TALKER.CMD < prev    next >
OS/2 REXX Batch file  |  1991-06-11  |  10KB  |  349 lines

  1.    S29 = "Talker  ver 1.1     " ; 20 chars long
  2.    S28 = "talker.ovl"           ; Our overlay file
  3.    S27 = "pc-vco.exc"           ; Our exception file
  4.    ON ESCAPE GOSUB Esc_Exit        ; ESC exit
  5. ;
  6. ; ----- Talker: Scripted interface to VOICE.EXE
  7. ;
  8. ;    R.McG; 3/90, Chicago
  9. ; ----------------------------------------------------------------
  10. ; Usages:
  11. ;      S29 -----> Legend line
  12. ;      S28 -----> Our own overlay file name
  13. ;      S27 -----> Our exception file
  14. ;      S26 -----> Previous overlay file name (or null)
  15. ;      S25 -----> Previous overlay entry point (or NONE)
  16. ;
  17. ; -----------------------------------------------------------------------
  18. ;
  19. ;    Initialization
  20. ;
  21. ;    Initial values
  22. ;
  23.    LEGEND S29                ; Display ourselves
  24.    S26 = "_OVERLAY"                     ; Save previous overlay, if any
  25.    S25 = "_OVENTRY"                     ; Save previous overlay entry point
  26. ;
  27. ;    Set-up the overlay (our interface to VOICE.EXE).
  28. ;    .. define an end-entry pt of '9' at the same time
  29. ;
  30.    OVERLAY S28    9            ; Load our overlay (end entry pt = 9)
  31.    IF FAILED                ; Stop here if can't load overlay
  32.       MESS "!Cannot overlay file: "*S28*"!"
  33.       GOTO Exit
  34.       ENDIF
  35. ;
  36. ;    Use the overlay to 'open' the driver
  37. ;
  38.    SCALL 6,N0                ; Entry addr 6 -> open_talk
  39.    IF NOT ZERO N0            ; If anything but zero rtnd
  40.       MESS "!Cannot open voice driver!"
  41.       IF NOT ISFILE "voice.exe" MESS "!VOICE.EXE must be on current subdir!"
  42.       GOTO Exit
  43.       ENDIF
  44. ;
  45. ;    Load an exception file, if its present
  46. ;
  47.    SCALL 12,S27,N0            ; Entry addr 12 -> Load exception file
  48.    IF NOT ZERO N0            ; If anything but zero rtnd
  49.       MESS "!Exception file load error: "*N0*" using: "*S27*"!"
  50.       ENDIF                ; Not fatal error
  51.    GOTO Loop                ; And start
  52. ;
  53. ;    Script termination
  54. ;
  55. Exit:
  56.    IF OVERLAY SCALL 9            ; Entry addr 9 -> Close voice driver
  57.    OVERLAY CLEAR            ; Clear our own
  58.    IF NOT NULL S26            ; If there was a previous,
  59.       OVERLAY S26 S25            ; .. replace it and its end action
  60.       ENDIF
  61.    EXIT
  62. ;
  63. ;    Escape pressed
  64. ;
  65. Esc_Exit:
  66.    S0 = "Do you wish to terminate TALKER?"
  67.    GOSUB Ask_YN             ; Prompt
  68.    IF FAILED RETURN            ; "N" -> continue
  69.    GOTO Exit                ; Terminate
  70. ;
  71. ;    Wait for something
  72. ;
  73. Loop:
  74.    WHILE FKEY or NOT RECEIVE        ; While nothing being received
  75.      IF FKEY GOTO Fkey        ; Skip if a func key pending
  76.      ENDWHILE            ; .. loop to make kbd fast
  77.    RGET S0 80 10            ; Get 80 chars - wait up to 10 secs
  78.    IF FAILED GOTO Loop            ; IF nothing received, Loop
  79.    SCALL 0,S0                ; Pass buffer to the driver
  80.    IF NOT FULL GOTO Loop        ; If not full rcv buffer
  81. ;
  82. ;    Flush the rcv buffer
  83. ;
  84.    LEGEND S29*"Flushing buffer"         ; Change legend
  85.    WHILE FULL                ; While buffer full (host xoffed)
  86.      RGET S0 80 30            ; Read a line and display, no voice
  87.      ENDWHILE            ;
  88.    LEGEND S29                ; Replace legend
  89.    GOTO Loop                ; And loop
  90. ;
  91. ;    Function key pending
  92. ;
  93. Fkey:
  94.    KEYGET S0                ; Read the function key
  95.    SWITCH S0
  96.       CASE "2E00"                       ; Alt-C
  97.      CLEAR (text)            ; Perform
  98.      LEGEND S29            ; Repaint legend
  99.       ENDCASE
  100.       CASE "1200"                       ; Alt-E
  101.      GOTO Echo
  102.       ENDCASE
  103.       CASE "2C00"                       ; Alt-Z
  104.      GOTO Mask
  105.       ENDCASE
  106.       CASE "2600"                       ; Alt-L
  107.      GOTO ScrSize
  108.       ENDCASE
  109.       CASE "2300"                       ; Alt-H
  110.      HANGUP             ; perform
  111.       ENDCASE
  112.       CASE "2200"                       ; Alt-G
  113.      GOTO Blnkln
  114.       ENDCASE
  115.       CASE "2D00"                       ; Alt-X
  116.      GOTO EndPgm
  117.       ENDCASE
  118.  
  119.       CASE "7500"                       ; Ctl-End
  120.      BREAK                ; Perform
  121.       ENDCASE
  122.       CASE "7200"                       ; Ctl-PrtSc
  123.      GOTO Printer
  124.       ENDCASE
  125.  
  126.       CASE "7800"                       ; Alt-1
  127.      MACRO 1            ; Perform
  128.       ENDCASE
  129.       CASE "7900"                       ; Alt-2
  130.      MACRO 2            ; Perform
  131.       ENDCASE
  132.       CASE "7A00"                       ; Alt-3
  133.      MACRO 3            ; Perform
  134.       ENDCASE
  135.       CASE "7B00"                       ; Alt-4
  136.      MACRO 4            ; Perform
  137.       ENDCASE
  138.       CASE "7C00"                       ; Alt-5
  139.      MACRO 5            ; Perform
  140.       ENDCASE
  141.       CASE "7D00"                       ; Alt-6
  142.      MACRO 6            ; Perform
  143.       ENDCASE
  144.       CASE "7E00"                       ; Alt-7
  145.      MACRO 7            ; Perform
  146.       ENDCASE
  147.       CASE "7F00"                       ; Alt-8
  148.      MACRO 8            ; Perform
  149.       ENDCASE
  150.       CASE "8000"                       ; Alt-9
  151.      MACRO 9            ; Perform
  152.       ENDCASE
  153.       CASE "8100"                       ; Alt-0
  154.      MACRO 0            ; Perform
  155.       ENDCASE
  156.  
  157.       CASE "4100"                       ; F7
  158.      GOTO Log
  159.       ENDCASE
  160.       CASE "4300"                       ; F9
  161.      GOTO LogHold
  162.       ENDCASE
  163.       CASE "4400"                       ; F10
  164.      GOSUB Help            ; Note uncharacteristic GOSUB
  165.       ENDCASE
  166.       CASE "7100"                       ; Alt-F10
  167.      SHELL                ; Shell to DOS
  168.       ENDCASE
  169.       ;
  170.       ; Other keypresses are unrecognized
  171.       ;
  172.       DEFAULT
  173.      SOUND 100,100            ; Signal error
  174.       ENDCASE
  175.    ENDSWITCH
  176.    GOTO Loop                ; And continue
  177. ;
  178. ;    End pgm
  179. ;
  180. EndPgm:
  181.    SET TTHRU ON         ; Inhibit type-through
  182.    STACK "^@-"                  ; Stack another Alt-X
  183.    GOTO Exit            ; End script (and COM-AND)
  184. ;
  185. ;    Toggle echo
  186. ;
  187. Echo:
  188.    IF STRCMP "_DUPL" "HALF"     ; Test current setting
  189.       SET DUPLEX FULL        ; .. toggle
  190.    ELSE SET DUPLEX HALF     ; .. toggle
  191.    GOTO Loop            ; And continue
  192. ;
  193. ;    Toggle mask
  194. ;
  195. Mask:
  196.    IF STRCMP "_MASK" "ON "      ; Test current setting
  197.       SET MASK OFF        ; .. toggle
  198.    ELSE SET MASK ON        ; .. toggle
  199.    GOTO Loop            ; And continue
  200. ;
  201. ;    Toggle screen size
  202. ;
  203. ScrSize:
  204.    IF GT "_SSIZ" 25
  205.       SET 25            ; .. toggle
  206.    ELSE SET 43            ; .. toggle
  207.    LEGEND S29            ; Repaint legend
  208.    GOTO Loop            ; And continue
  209. ;
  210. ;    Toggle printer
  211. ;
  212. Printer:
  213.    IF STRCMP "_PRINT" "ON "     ; Test state
  214.       PRINTER OFF        ; .. toggle
  215.    ELSE PRINTER ON
  216.    GOTO Loop            ; And continue
  217. ;
  218. ;    Toggle the blank line eater
  219. ;
  220. Blnkln:
  221.    IF STRCMP "_BSUP" "ON "      ; Test current setting
  222.       SET BSUPPRESS OFF     ; .. toggle
  223.    ELSE SET BSUPPRESS ON    ; .. toggle
  224.    GOTO Loop            ; And continue
  225. ;
  226. ;    Toggle the log function
  227. ;
  228. Log:
  229.    IF STRCMP "_LOGG" "OFF"
  230.       S1 = "Enter the transcript file name:"
  231.       GOSUB Ask_File        ; Get script file name
  232.       IF NOT SUCCESS or NULL S0 ; IF ESC'd out
  233.      GOTO Loop
  234.      ENDIF
  235.       LOG OPEN S0
  236.    ELSE
  237.       LOG CLOSE
  238.       ENDIF
  239.    GOTO Loop            ; Set-up the line to add to output
  240. ;
  241. ;    Toggle the log hold function
  242. ;
  243. LogHold:
  244.    IF STRCMP "_LOGG" "OFF"      ; If not logging
  245.       GOTO Loop
  246.       ENDIF
  247.    IF STRCMP "_LOGH" "OFF"
  248.       LOG SUSPEND
  249.    ELSE LOG RESUME
  250.    GOTO Loop            ; Set-up the line to add to output
  251. ;
  252. ; ----- Subroutine: Ask for a script file name
  253. ;    S1 passes the prompt used
  254. ;    SUCCESS returns fact script file successfully opened
  255. ;    S0 returns the fname
  256. ;
  257. Ask_File:
  258.    WOPEN 10 10 13 70 (contrast) ASK_ESC
  259.    ATSAY 10 12 (contrast) " TALKER Fname "
  260.    ATSAY 11 12 (contrast) S1(0:56)
  261.    ATSAY 13 30 (contrast) " Press ESC to cancel "
  262.  
  263.    ATGET 12 12 (contrast) 54 S0; Read new fname
  264.    WCLOSE
  265.    ;
  266.    ;       Attempt to execute the entry
  267.    ;
  268.    LJ S0            ; Left justify
  269.    S0 = S0 &""                  ; Trim spaces
  270.    UPPER S0            ; Make pretty
  271.    IF NOT NULL S0        ; If nothing entered
  272.       SET SUCCESS ON
  273.    ELSE
  274.       SET SUCCESS OFF
  275.       ENDIF
  276.    RETURN            ; And done
  277. ;
  278. ; ----- Escape during a subwindow
  279. ;    .. S0 is returned null
  280. ;
  281. Ask_Esc:
  282.    S0 = ""                      ; Make a null return
  283.    RETURN
  284. ;
  285. ; ----- Subroutine: Ask a question and take a y/n answer
  286. ;    S0 passes the text to be displayed
  287. ;    SUCCESS returns fact of y/n
  288. ;
  289. Ask_YN:
  290.    WOPEN 10 10 13 70 (contrast) ASK_ESC
  291.    ATSAY 10 12 (contrast) " Talker Y/N "
  292.    ATSAY 11 12 (contrast) S0(0:55)
  293.    ATSAY 13 30 (contrast) " CR or ESC to exit "
  294.  
  295.    ATGET 12 12 (contrast) 1 S0 ; Read y/n
  296.    WCLOSE
  297.    ;
  298.    ;       Interperet the response
  299.    ;
  300.    IF NULL S0 or FIND S0 "Y"    ; If c/r yes
  301.       SET SUCCESS ON
  302.    ELSE
  303.       SET SUCCESS OFF
  304.       ENDIF
  305.    RETURN            ; And done
  306. ;
  307. ; --